# Description: SMB Dosya sunucusu ve AD Etki Alanı sunucusu
# URL: http://www.samba.org
# Packager: milisarge
# Depends on: talloc tevent avahi gnutls libgpg-error popt python cups kerberos libcap tdb openldap libxslt

name=samba
version=4.4.5
release=1

source=( http://ftp.samba.org/pub/samba/stable/$name-$version.tar.gz
http://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-20170225.tar.xz)

build() {

if [ "`uname -m`" == "x86_64" ]; then
        LIB=lib64
else
        LIB=lib
fi
cd $name-$version


./configure                             \
    --prefix=/usr                       \
    --sysconfdir=/etc                   \
    --localstatedir=/var                \
    --with-piddir=/run/samba            \
    --with-pammodulesdir=/lib/security  \
    --without-ad-dc                     \
    --enable-fhs                        \
    --without-systemd                   \
    --bundled-libraries=!tdb,!talloc,!pytalloc-util,!tevent,!popt,!ldb

make

sed -i "/samba3.blackbox.failure.failure/i \^samba3.raw.eas" selftest/knownfail

make DESTDIR=$PKG install

install -d $PKG/$LIB
mv -v $PKG/usr/lib/libnss_win{s,bind}.so*   $PKG/$LIB
ln -v -sf /$LIB/libnss_winbind.so.2 $PKG/usr/lib/libnss_winbind.so
ln -v -sf /$LIB/libnss_wins.so.2    $PKG/usr/lib/libnss_wins.so
   
install -v -m644 examples/smb.conf.default $PKG/etc/samba/smb.conf.default

mkdir -pv $PKG/etc/openldap/schema
install -v -m644 examples/LDAP/README \
$PKG/etc/openldap/schema/README.LDAP

install -v -m644 examples/LDAP/samba* \
$PKG/etc/openldap/schema

install -v -m755 examples/LDAP/{get*,ol*} \
$PKG/etc/openldap/schema


#  cups 
cd $PKG/usr/lib/
install -d cups/backend
ln -v -sf $PKG/usr/bin/smbspool $PKG/usr/lib/cups/backend/smb

# servis
cd $SRC/blfs-bootscripts-20170225
make DESTDIR=$PKG install-samba
make DESTDIR=$PKG install-winbindd

# Doublon
rm -f $PKG/usr/lib/python2.7/site-packages/talloc.so
}
